package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-24
 * Time: 17:07
 */
public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println();
        System.out.println("=====增添图书=====");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您所要添加图书的书名：");
        String name = scanner.nextLine();
        System.out.println("请输入您所要添加图书的作者：");
        String author = scanner.nextLine();
        System.out.println("请输入您所要添加图书的价格：");
        int price = scanner.nextInt();
        scanner.nextLine();
        System.out.println("请输入您所要添加图书的类型：");
        String type = scanner.nextLine();
        Book book = new Book(name, author, price, type);
        int currentSize = bookList.getUsedSize();
        bookList.setBook(currentSize,book);
        bookList.setUsedSize(currentSize + 1);
        System.out.println("成功添加该图书！！！");
        System.out.println();
    }
}
